package com.xilihui.xlh.business.activitys;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.xilihui.xlh.R;
import com.xilihui.xlh.business.fragments.MyChecklistFragment;
import com.xilihui.xlh.business.fragments.StoreFragment;
import com.xilihui.xlh.core.app.BaseCompatActivity;
import com.xilihui.xlh.core.util.LogUtil;
import com.xilihui.xlh.core.util.YEventBuses;
import com.xyz.library.TabLayout;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/5/28.
 */

public class MyChecklistActivity extends BaseCompatActivity{
    
    @BindView(R.id.tablayout)
    TabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    
    String wa_id = "";
    String agent_id = "";
    
    @Override
    public int getLayout() {
        return R.layout.activity_my_checklist;
    }

    @Override
    public String initTitle() {
        return "我的清单";
    }

    @Override
    public void initUI(@Nullable Bundle savedInstanceState) {
        
        wa_id = (String)getIntent().getStringExtra("wa_id");
        agent_id = (String)getIntent().getStringExtra("agent_id"); 
        
        viewPager.setOffscreenPageLimit(4);
        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                MyChecklistFragment myChecklistFragment = new MyChecklistFragment();
                Bundle bundle = new Bundle();
                bundle.putString("wa_id",wa_id);
                bundle.putString("agent_id",agent_id);
                bundle.putInt("status",position);
                myChecklistFragment.setArguments(bundle);
                return myChecklistFragment;
            }
            
            @Override
            public int getCount() {
                return 5;
            }
            
        });
        
        tabLayout.setViewPager(viewPager);
        
    }

    @Override
    public void initData() {

    }

    @Override
    public void onEventMainThread(YEventBuses.Event event) {
        super.onEventMainThread(event);
        if(event.is("yifukuang")){
            viewPager.setCurrentItem(2);
            LogUtil.i("mylog","2ddddd");
        }
    }
}
